﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;
public partial class System_MasterPageDeparment : System.Web.UI.MasterPage
{
    public string _SCSort = "0";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Account"] != null)
        {
            HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
            if ((Request.UserHostAddress == "125.46.74.27") || (Request.UserHostAddress == "125.46.74.28") || (Request.UserHostAddress == "125.46.74.26"))
            {     
            }
            else
            {
                //Response.Write("<script>alert('请在内部网络使用!');location.href='../HomePage/Default.aspx';</script>");
                //Response.Write("<script>alert('请在内部网络使用！');</script>");
                //Response.Redirect("../HomePage/Default.aspx");
            }
            _SCSort = _Account.AC_SORT.ToString();
            HZ.MBSM.DAL.AccountType _AccountType = (HZ.MBSM.DAL.AccountType)SysFun.ToInt(_Account.Type);

            string strPageDescribePath = Server.MapPath("../System/PageDescribe.xml");
            HZ.MBSM.BLL.PageDescribeCollection _PageDescribeCollection = new HZ.MBSM.BLL.PageDescribeCollection();
            _PageDescribeCollection.LoadXML(strPageDescribePath);

            foreach (HZ.MBSM.BLL.PageDescribe _PageDescribe in _PageDescribeCollection.ChildrenPageDescribe)
            {
                for (int intIndex = _PageDescribe.ChildrenPageDescribe.Count - 1; intIndex >= 0; intIndex--)
                {
                    bool bolIsChecked = false;

                    foreach (HZ.MBSM.DAL.AccountType _AccountTypePage in _PageDescribe.ChildrenPageDescribe[intIndex].UseAccountType)
                    {
                        if (_AccountTypePage == _AccountType)
                        {
                            bolIsChecked = true;
                            break;
                        }
                    }

                    if (bolIsChecked == false)
                    {
                        _PageDescribe.ChildrenPageDescribe.RemoveAt(intIndex);
                    }
                }
            }

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("<table width='232' border='0' cellspacing='0' cellpadding='0'>");
            sb.Append("<tr><td><img src='../Images/2_left_title1.jpg' width='232' height='14'></td></tr>");
            sb.Append("<tr><td align='center' background='../Images/left_bg.jpg'>");
            sb.Append("<table width='217' border='0' cellspacing='4' cellpadding='0'>");
            sb.Append("<tr><td>");
            sb.Append("<table width='100%' border='0' cellspacing='0' cellpadding='0'>");
            sb.Append("<tr>");
            sb.Append("<td></td>");//<img src='../Images/logo_JD.gif' with='232'/>
            sb.Append("</tr>");
            sb.Append("<tr>");
            sb.Append("<td class='mm_left_bg' ><img src='../Images/spacer.gif' width='40' height='10'><strong><span style=‘font-family: 宋体'>欢迎 <font color='#0066CC'>" + _Account.DWName + " </font> 登录系统</span></strong></td>");
            sb.Append("</tr>");
            //sb.Append("<tr>");
            //sb.Append("<td class='mm_left_bg'><img src='../images/spacer.gif' width='40' height='10'><strong><span style=‘font-family: 宋体'>用户名:<font color='#0066cc'>" + _Account.AccountName + "</font> </span></strong></td>");
            //sb.Append("</tr>");
            sb.Append("<tr>");
            sb.Append("<td class='mm_left_bg'><img src='../Images/spacer.gif' width='40' height='10'><strong><span style=‘font-family: 宋体'>注册号:<font color='#0066CC'>" + _Account.UserCode + "</font></span></strong> </td>");
            sb.Append("</tr>");
           // sb.Append("<tr><td class='mm_left_bg2'><img src='../Images/spacer.gif' width='40' height='10'>");
           // sb.Append("<a href='../Deparment/Noneperson.aspx'><strong><span style='font-family: 宋体'>◇个人资料</span></strong></a>");
           // sb.Append("</td></tr>");
            sb.Append("<tr><td class='mm_left_bg2'><img src='../Images/spacer.gif' width='40' height='10'>");
            sb.Append("<a href='../Deparment/Worker/PassWordChange.aspx' target='black'><strong><span style='font-family: 宋体'>◇修改密码</span></strong></a>");
            sb.Append("</td></tr>");
            sb.Append("<tr><td class='mm_left_bg2'><img src='../Images/spacer.gif' width='40' height='10'>");
            sb.Append("<a href='../HomePage/Logout.aspx'><strong><span style='font-family: 宋体'>◇安全退出</span></strong></a>");
            sb.Append("</td></tr>");

            foreach (HZ.MBSM.BLL.PageDescribe _PageDescribe in _PageDescribeCollection.ChildrenPageDescribe)
            {
                if (_PageDescribe.ChildrenPageDescribe.Count > 0)
                {
                    sb.Append("<tr><td>");
                    sb.Append("<table width='100%' border='0' cellspacing='0' cellpadding='0'>");
                    sb.Append("<tr>");
                    sb.Append("<td class='mm_left_bg' style='behavior:url(../System/ItemSortPucker.htc)'><img src='../Images/spacer.gif' width='40' height='10'><strong><span style=‘font-family: 宋体'>" + _PageDescribe.Name + "</span></strong></td>");
                    sb.Append("</tr>");
                    sb.Append("<tr><td><table width='100%' border='0' cellspacing='0' cellpadding='0'>");

                    foreach (HZ.MBSM.BLL.PageDescribe _PageDescribeChildren in _PageDescribe.ChildrenPageDescribe)
                    {
                        sb.Append("<tr><td class='mm_left_bg2'><img src='../Images/spacer.gif' width='40' height='10'>");
                        sb.Append("<a href='" + _PageDescribeChildren.Url + "'><strong><span style=‘font-family: 宋体'>◇" + _PageDescribeChildren.Name + "</span></strong></a>");
                        sb.Append("</td></tr>");
                    }

                    sb.Append("</table></td></tr>");
                    sb.Append("</table>");
                    sb.Append("</td></tr>");
                }
            }

            sb.Append("</table>");
            sb.Append("</td></tr>");
            sb.Append("</table>");
            sb.Append("</td></tr><tr><td><img src='../Images/left_bottom.jpg' width='232' height='14'></td></tr>");
            sb.Append("</table>");
            labPage.Text = sb.ToString();
        }
        else
        {
            Response.Redirect("../HomePage/Default.aspx");
        }
    }
}
